<%@page import="utils.PageUtil"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="dao.TopicDao"%>
<%@page import="pojo.Topic"%>
<%@page import="dao.NewsDao"%>
<%@ page language="java" import="java.util.*,pojo.News,pojo.News_users"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<title>新闻中国</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script language="javascript">
	function check() {
		var login_username = document.getElementById("uname");
		var login_password = document.getElementById("upwd");
		if (login_username.value == "") {
			alert("用户名不能为空！请重新填入！");
			login_username.focus();
			return false;
		} else if (login_password.value == "") {
			alert("密码不能为空！请重新填入！");
			login_password.focus();
			return false;
		}
		return true;
	}

	function focusOnLogin() {
		var login_username = document.getElementById("uname");
		login_username.focus();
	}
</script>
</head>




<%
	String uname = "", upwd = "";
	Cookie[] cookies = request.getCookies();
	for (int i = 0; cookies != null && i < cookies.length; i++) {
		if (cookies[i].getName().equals("uname")) {
			uname = URLDecoder.decode(cookies[i].getValue(), "utf-8");
		}
		if (cookies[i].getName().equals("upwd")) {
			upwd = cookies[i].getValue();
		}
	}
%>

<body onload="focusOnLogin()">

	<div id="header">


		<div id="top_login">
			<%
				Object oo = session.getAttribute("USER_LOGIN");
				if (oo != null) {
			%>
			<p>
				欢迎管理员<%=((News_users) session.getAttribute("USER_LOGIN")).getUname()%>
			<p>
				<%
					} else {
				%>
			
			<form action="util/do_login.jsp" method="post"
				onsubmit="return check()">
				<label> 登录名 </label> <input type="text" name="uname" id="uname"
					value="<%=uname%>" class="login_input" /> <label>
					密&#160;&#160;码 </label> <input type="text" name="upwd" id="upwd"
					value="<%=upwd%>" class="login_input" /> <input type="checkbox"
					name="keep" id="keep" value="1" />记住我的登录状态 <input type="submit"
					class="login_sub" value="登录" /> <label id="error"> </label> <img
					src="images/friend_logo.gif" alt="Google" id="friend_logo" />
			</form>
			<%
				}
			%>
		</div>
		<div id="nav">
			<div id="logo">
				<img src="images/logo.jpg" alt="新闻中国" />
			</div>
			<div id="a_b01">
				<img src="images/a_b01.gif" alt="" />
			</div>
			<!--mainnav end-->
		</div>
	</div>
	<div id="container">




		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		<div class="sidebar">
			<h1>
				<img src="images/title_1.gif" alt="国内新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<%
						List<News> newsGN = NewsDao.doSearchTopX(1);

						for (int i = 0; newsGN != null && i < newsGN.size(); i++) {
					%>

					<li><a href='news.jsp?nid=<%=newsGN.get(i).getNid()%>'><b>
								<%=newsGN.get(i).getNtitle()%></b></a></li>
					<%
						}
					%>




				</ul>
			</div>
			<h1>
				<img src="images/title_2.gif" alt="国际新闻" />
			</h1>
			<div class="side_list">
				<ul>

					<%
						List<News> newsGJ = NewsDao.doSearchTopX(2);

						for (int i = 0; newsGJ != null && i < newsGJ.size(); i++) {
					%>

					<li><a href='news.jsp?nid=<%=newsGJ.get(i).getNid()%>'><b>
								<%=newsGJ.get(i).getNtitle()%></b></a></li>
					<%
						}
					%>

				</ul>
			</div>
			<h1>
				<img src="images/title_3.gif" alt="娱乐新闻" />
			</h1>
			<div class="side_list">
				<ul>

					<%
						List<News> newsYL = NewsDao.doSearchTopX(3);

						for (int i = 0; newsYL != null && i < newsYL.size(); i++) {
					%>

					<li><a href='news.jsp?nid=<%=newsYL.get(i).getNid()%>'><b>
								<%=newsYL.get(i).getNtitle()%></b></a></li>
					<%
						}
					%>

				</ul>
			</div>
		</div>
		<div class="main">
			<div class="class_type">
				<img src="images/class_type.gif" alt="新闻中心" />
			</div>
			<div class="content">
				<ul class="class_date">
					<%
						List<Topic> list1 = TopicDao.doTopicSearch();
						int count = 0;
						for (int i = 0; i < list1.size(); i++) {
							if (i % 11 == 0) {
					%>
					<li id='class_month'>
						<%
							}
						%> <a href="index.jsp?opr=topicNew&tid=<%=list1.get(i).getTid()%>"><b><%=list1.get(i).getTname()%>
						</b></a> <%
 	count++;
 		if (list1.size() % 11 == 0) {
 			if (count == 11) {
 %>
					</li>
					<%
						count = 0;
								}
							} else {
								if (count == 11 || i == list1.size() - 1) {
					%>
					</li>
					<%
						count = 0;
								}
							}

						}
					%>

				</ul>
				<ul class="classlist">

					<%
						int count1 = 0;
						Integer tid, pageNo;
						tid = request.getParameter("tid") == null ? null : Integer.parseInt(request.getParameter("tid"));
						pageNo = request.getParameter("pageNo") == null ? 1 : Integer.parseInt(request.getParameter("pageNo"));

						PageUtil<News> pageutil = NewsDao.doPageSearch(pageNo, tid);

						List<News> list = pageutil.getNews();

						for (News news : list) {
					%>
					<li><a href='news.jsp?opr=readNew&nid=<%=news.getNid()%>'><%=news.getNtitle()%>
					</a><span> <%=news.getNcreateDate()%>
					</span></li>
					<%
						count1++;
							if (count1 == 5) {
					%>
					<br />
					<%
						count1 = 0;
							}
						}
					%>

					<p align="right">
						<%
							if (pageutil.getPage() != 1) {
						%>
						<a
							href="index.jsp?pageNo=<%=pageutil.getPage() - 1%><%=tid == null ? "" : "&tid=" + tid%>">上一页</a>
						<%
							}
						%>
						<%
							if (pageutil.getPage() != pageutil.getTotalPage()) {
						%>
						<a
							href="index.jsp?pageNo=<%=pageutil.getPage() + 1%><%=tid == null ? "" : "&tid=" + tid%>">下一页</a>
						<%
							}
						%>
						当前页数:[
						<%=pageutil.getPage()%>/<%=pageutil.getTotalPage()%>
						]
					</p>

				</ul>
			</div>
			<div class="picnews">
				<ul>
					<li><a href="#"><img src="images/Picture1.jpg" width="249"
							alt="" /> </a><a href="#">幻想中穿越时空</a></li>
					<li><a href="#"><img src="images/Picture2.jpg" width="249"
							alt="" /> </a><a href="#">国庆多变的发型</a></li>
					<li><a href="#"><img src="images/Picture3.jpg" width="249"
							alt="" /> </a><a href="#">新技术照亮都市</a></li>
					<li><a href="#"><img src="images/Picture4.jpg" width="249"
							alt="" /> </a><a href="#">群星闪耀红地毯</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div id="friend">
		<h1 class="friend_t">
			<img src="images/friend_ico.gif" alt="合作伙伴" />
		</h1>
		<div class="friend_list">
			<ul>
				<li><a href="#">百度</a></li>
				<li><a href="#">谷歌</a></li>
				<li><a href="#">新浪</a></li>
				<li><a href="#">网易</a></li>
				<li><a href="#">搜狐</a></li>
				<li><a href="#">人人</a></li>
				<li><a href="#">中国政府网</a></li>
			</ul>
		</div>
	</div>
	<div id="footer">
		<p class="">
			24小时客户服务热线：010-68988888 &#160;&#160;&#160;&#160; <a href="#">常见问题解答</a>
			&#160;&#160;&#160;&#160; 新闻热线：010-627488888 <br />
			文明办网文明上网举报电话：010-627488888 &#160;&#160;&#160;&#160; 举报邮箱： <a href="#">jubao@jb-aptech.com.cn</a>
		</p>
		<p class="copyright">
			Copyright &copy; 1999-2009 News China gov, All Right Reserver <br />
			新闻中国 版权所有
		</p>
	</div>
</body>
</html>
</body>

</html>
